'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  //测试相关
  router.get('/', controller.home.index);
  // router.get('/hello',app.middleware.checktoken() ,controller.hello.index);

  //登录相关
  router.post('/api/login',controller.admin.login);
  //注册相关
  router.post('/api/createUser',controller.users.create);
  //获取信息列表
  router.get('/api/getInfoList',controller.message.getInfoList);
  //发表信息
  router.post('/api/createMessage',controller.message.createMessage);
  //获取指定id的信息
  router.get('/api/getMessageDetail',controller.message.getMessageDetail);
  //删除指定id的信息
  router.delete('/api/deleteIdMessage/:id',controller.message.deleteIdMessage);

  router.resources('users', '/api/users', controller.users);
  router.post('/api/users',controller.users.create);
  router.delete('/api/users/:id',controller.users.deleteUser);
  router.put('/api/users/',controller.users.update);
  router.get('/api/users',controller.users.getUserList);
};
